package com.nowcoder.community.entity;

import java.util.HashMap;
import java.util.Map;

/**
 * @ClassName Event
 * @Description
 * @Author hhwu
 * @Date 2022/5/27 10:07
 * Version 1.0
 **/
public class Event {
    /**
     * @Author hhwu
     * @Description //TODO 定义消息队列中的一个事件.每个set方法也返回提个event对象，这样可以灵活设置任意属性
     * @Date 10:10 2022/5/27
     **/
    private String topic;
    private int userId;// 触发事件的人
    private int entityType;// 实体的类型
    private int entityId;// 实体id
    private int entityUserId;// 实体的拥有者id
    private Map<String, Object> data = new HashMap<>();

    @Override
    public String toString() {
        return "Event{" +
                "topic='" + topic + '\'' +
                ", userId=" + userId +
                ", entityType=" + entityType +
                ", entityId=" + entityId +
                ", entityUserId=" + entityUserId +
                ", data=" + data +
                '}';
    }

    public String getTopic() {
        return topic;
    }

    public Event setTopic(String topic) {
        this.topic = topic;
        return this;
    }

    public int getUserId() {
        return userId;
    }

    public Event setUserId(int userId) {
        this.userId = userId;
        return this;
    }

    public int getEntityType() {
        return entityType;
    }

    public Event setEntityType(int entityType) {
        this.entityType = entityType;
        return this;
    }

    public int getEntityId() {
        return entityId;
    }

    public Event setEntityId(int entityId) {
        this.entityId = entityId;
        return this;
    }

    public int getEntityUserId() {
        return entityUserId;
    }

    public Event setEntityUserId(int entityUserId) {
        this.entityUserId = entityUserId;
        return this;
    }

    public Map<String, Object> getData() {
        return data;
    }

    public Event setData(String key, Object value) {
        this.data.put(key, value);
        return this;
    }
}
